#include "population.hpp"
#include "generation.hpp"
#include "node_list.hpp"
#include "generation_table.hpp"

#include <fstream>
#include <iostream>
#include <ctime>

int main(int argc, char* argv[]) {
    time_t start_time = time(NULL);
    pleasure::population pop;
    pleasure::node_list nlist;
    std::ifstream in("node_list");
    while (!in.eof()) {
        pleasure::stream_to_node_list(in, nlist);
    }
    pleasure::generation_table gtable;
    combo::type_tree ttree(combo::id::lambda_type);
    combo::type_tree::post_order_iterator it = ttree.begin_post();
    ttree.append_child(it, combo::id::boolean_type);
    ttree.append_child(it, combo::id::boolean_type);
    ttree.append_child(it, combo::id::boolean_type);
    ttree.append_child(it, combo::id::boolean_type);
    ttree.append_child(it, combo::id::boolean_type);
    pleasure::generate_generation_table(nlist, ttree, gtable);
    pleasure::enumerate_program_trees(gtable, 3, ttree, pop);
    pleasure::reduce(pop, combo::type_tree_arity(ttree), reduct::logical_reduction());
    for (pleasure::population::iterator it = pop.begin(); it != pop.end(); it++) {
        std::cout<<*it<<std::endl;
    }
    std::cout<<"Running time: "<<difftime(time(NULL), start_time)<<std::endl;
};
